﻿using RestSharp;
using RestSharp.Authenticators;
using System;
using System.Linq;
namespace JHECIS
{
    internal class ApiAuthenticator : IAuthenticator
    {
        private readonly string authHeader;

        public ApiAuthenticator()
        {
            this.authHeader = "jhecis";
        }

        public void Authenticate(IRestClient client, IRestRequest request)
        {
            if (!request.Parameters.Any(p => "auth".Equals(p.Name, StringComparison.OrdinalIgnoreCase)))
                request.AddParameter("auth", authHeader, ParameterType.HttpHeader);
        }
    }
}
